// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   DbConnect.java

package team.common.config;

import java.io.PrintStream;
import java.net.InetAddress;
import java.sql.*;
import java.text.DecimalFormat;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class DbConnect
{

    public DbConnect()
    {
    }

    public static Connection getConnection()
        throws NamingException, SQLException
    {
        String JDBC_DRIVER = "org.mariadb.jdbc.Driver";
        String JDBC_URL = "jdbc:mariadb://59.14.134.11:3306/baguni?autoReconnect=true";
        System.out.println((new StringBuilder("--------------------")).append(JDBC_URL).append("-------------------------").toString());
        try
        {
            Class.forName(JDBC_DRIVER);
            connection = DriverManager.getConnection(JDBC_URL, "root", "rldyd311");
        }
        catch(ClassNotFoundException e)
        {
            System.out.println(e.toString());
        }
        catch(SQLException e)
        {
            System.out.println((new StringBuilder("SQLException : ")).append(e.toString()).toString());
            throw e;
        }
        return connection;
    }
    
    public static Connection getConnection2()
            throws NamingException, SQLException
        {
            String JDBC_DRIVER = "org.mariadb.jdbc.Driver";
            String JDBC_URL = "jdbc:mariadb://59.14.134.11:3306/scfiat?autoReconnect=true";
            System.out.println((new StringBuilder("--------------------")).append(JDBC_URL).append("-------------------------").toString());
            try
            {
                Class.forName(JDBC_DRIVER);
                connection = DriverManager.getConnection(JDBC_URL, "root", "rldyd311");
            }
            catch(ClassNotFoundException e)
            {
                System.out.println(e.toString());
            }
            catch(SQLException e)
            {
                System.out.println((new StringBuilder("SQLException : ")).append(e.toString()).toString());
                throw e;
            }
            return connection;
        }

    public static void printNewLogOut(String strMag)
    {
        if(glbnStandOut == 1)
            System.out.println(strMag);
    }

    public static String dateToNewString(String date)
    {
        try
        {
            String strRet = "";
            int len = date.trim().length();
            if(len == 6)
                strRet = (new StringBuilder(String.valueOf(date.substring(0, 4)))).append("/").append(date.substring(4, 6)).toString();
            else
            if(len == 8)
                strRet = (new StringBuilder(String.valueOf(date.substring(0, 4)))).append("/").append(date.substring(4, 6)).append("/").append(date.substring(6, 8)).toString();
            else
                strRet = date;
            return strRet;
        }
        catch(Exception ex)
        {
            return null;
        }
    }

    public static String commaToNewString(int nFlag, String strNum)
    {
        try
        {
            DecimalFormat df1 = new DecimalFormat("#,###,###,###,###,###,###,###,###.###");
            String strRet;
            if(nFlag == 1)
            {
                int nNum = Integer.parseInt(strNum);
                strRet = df1.format(nNum);
            } else
            if(nFlag == 2)
            {
                double dNum = Double.parseDouble(strNum);
                strRet = df1.format(dNum);
            } else
            {
                strRet = strNum;
            }
            return strRet;
        }
        catch(Exception ex)
        {
            return strNum;
        }
    }

    public static String commaToNewString(double dNum)
    {
        try
        {
            DecimalFormat df1 = new DecimalFormat("#,###,###,###,###,###,###,###,###.###");
            String strRet = df1.format(dNum);
            return strRet;
        }
        catch(Exception ex)
        {
            return null;
        }
    }

    public static String commaToNewString(int nNum)
    {
        try
        {
            DecimalFormat df1 = new DecimalFormat("#,###,###,###,###,###,###,###,###");
            String strRet = df1.format(nNum);
            return strRet;
        }
        catch(Exception ex)
        {
            return null;
        }
    }

    static final String dataSourceName = "LAND";
    private static Connection connection;
    private static DataSource dataSource;
    static int glbnStandOut = 0;

}
